a11y: Improve child index helpers
authorMatthias Clasen <mclasen@redhat.com>
Sat, 24 Oct 2020 17:14:44 +0000 (13:14 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 24 Oct 2020 17:14:44 +0000 (13:14 -0400)
We need to use gtk_accessible_should_present() whenever we
calculate accessible tree positions, to avoid inconsistencies.

While we are at it, make these helpers usable for finding
the position of accesibles that are now ignored, by not
looking at should_present for the object itself. This will
be relevant when we calculate the position of objects whose
HIDDEN state changes.

gtk/a11y/gtkatspicontext.c

index 2e838b1ef63bdbdb5b08b41dcaa8de29765df174..f223d13062865400ab5af6d6ccdff69dbe48b126 100644 (file)
@@ -347,12 +347,12 @@ get_index_in_parent (GtkWidget *widget)
        child;
        child = gtk_widget_get_next_sibling (child))
     {
-      if (!gtk_accessible_should_present (GTK_ACCESSIBLE (child)))
-        continue;
-
       if (child == widget)
         return idx;
 
+      if (!gtk_accessible_should_present (GTK_ACCESSIBLE (child)))
+        continue;
+
       idx++;
     }
 
@@ -374,12 +374,12 @@ get_index_in_toplevels (GtkWidget *widget)
 
       g_object_unref (window);
 
-      if (!gtk_widget_get_visible (window))
-        continue;
-
       if (window == widget)
         return idx;
 
+      if (!gtk_accessible_should_present (GTK_ACCESSIBLE (window)))
+        continue;
+
       idx += 1;
     }